<template>
  <div class="history_list">
    <InnerPageTable ref="listTable" :config="pageTableConfig">
    </InnerPageTable>
  </div>
</template>

<script>
import { generateColumns } from "./history-constant";
import { superviseInfoAPI } from "@api/superviseInfo";
import { stateHandleMix } from "@/views/superviseInfo/mix/stateHandleMix";
import detailPage from "@/components/detailInfo";
import { mapTable } from "@/tools/util";

export default {
  name: "historyList",
  props: ['row', 'path'],
  mixins: [stateHandleMix],
  data() {
    return {
      pageTableConfig: {
        loadDataFn: this.getTableList,
        columns: generateColumns.bind(this)(),
        autoFirst: true,
        initParam: {
          "crsrm_bidding_id": this.row.crsrmBiddingId,
          "crsrm_category_code": this.row.crsrmCategoryCode,
          "crsrm_supplier_social_credit": this.row.crsrmSupplierSocialCredit,
          "crsrm_industry_code": this.row.crsrmIndustryCode,
          "crsrm_contract_code": this.row.crsrmContractCode,
          "crsrm_seller_social_credit_code": this.row.crsrmSellerSocialCreditCode,
          "crsrm_purchaser_social_credit_code": this.row.crsrmPurchaserSocialCreditCode,
          "crsrm_purchaser_sbu": this.row.crsrmPurchaserSbu
        },
      },
    }
  },
  mounted() {
    this.init()
  },
  methods: {
    init() {
      this.$emit('SetTitle', '历史记录')
      this.$emit('SetPageWidth', 750)
    },
    detailHandle(id) {
      const urlPath = location.hash.substring(2,)
      this.$Spin.show()
      superviseInfoAPI.getHistoryDetail({ id: id }, mapTable[urlPath].historyDetailUrl).then(res => {
        this.$Spin.hide()
        const detailInfo = res.data
        this.$emit('Close')
        new this.$sidelipPage(detailPage, { props: { detailInfo, detailField: mapTable[urlPath].detailField, isHistory: true }, isNav: false });
      })
    },
    getTableList(tableObj) {
      let { responseProcess, initParam, param } = tableObj;
      const params = {
        ...param,
        ...initParam
      };
      superviseInfoAPI.getHistory(params, this.path).then(res => {
        responseProcess(res.data);
      })
    },
  }
};
</script>

<style lang="less">
.history_list{
  .fail, .warning, .pass{
    display: inline-block;
    padding: 0px 16px;
    border-radius: 20px;
    text-align: center;
  }
  .circle{
    width: 5px;
    height: 5px;
    border-radius: 100%;
    display: inline-block;
    position: relative;
    top: -2px;
    margin-right: 6px;
  }
  .fail{
    background: rgba(255, 33, 55, 0.08);
    color: #FF2137;
    .circle{
      background: #FF2137;
    }
  }
  .warning{
    background: rgba(250, 192, 50, 0.08);
    color: #FAC032;
    .circle{
      background: #FAC032;
    }
  }
  .pass{
    background: rgba(0, 191, 78, 0.08);
    color: #00BF4E;
    .circle{
      background: #00BF4E;
    }
  }
}
</style>
